package org.paradise.dms.util;

import message.sms.SUBMIT_RESP;

import org.apache.log4j.Logger;
import org.paradise.dms.dao.impl.RespStationDaoImpl;
import org.paradise.dms.pojo.RespStation;

import common.ComFun;


@SuppressWarnings("unchecked")
public class FindSubmitResp1 extends Thread {
	private static Logger logger = Logger.getLogger(FindSubmitResp1.class);
	
    
	private RespStation respStation;
	public RespStation getRespStation() {
		return respStation;
	}
	public void setRespStation(RespStation respStation) {
		this.respStation = respStation;
	}
	
	public void run() {
		SUBMIT_RESP submit_Resp = new SUBMIT_RESP();
		while (true) {
			try {
				if ((submit_Resp = ComFun.getSubmitResp()) != null) {
					
					logger.info("-MAS接收到的短信＝" 
							+"企业端消息标识 ["+submit_Resp.getSendId()+"]+"
							+ "MAS下行消息ID ["+ submit_Resp.getSubmitReserve() + "]+"
							+ "下行消息状态 [" + submit_Resp.getSubmitResult() + "]+"
							+ "目的号码 [" + submit_Resp.getDestID() + "]+"
							+ "短信内容 [" + submit_Resp.getMsgContent() + "]\n");
					RespStation respStation = new RespStation();
					respStation.setSendId(submit_Resp.getSendId());
					respStation.setSubmitReserve(submit_Resp.getSubmitReserve());
					RespStationDaoImpl respStationDao = new RespStationDaoImpl();
					respStationDao.add(respStation);
				} else {
					sleep(1000);

				}
			} catch (Exception e) {
				logger.error(this,e);

			}
		}
	}
}